﻿<template>
  <a-modal
    title="编辑医保退费"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="PSN_NO " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入PSN_NO " v-decorator="['psnNo']" />
        </a-form-item>
        <a-form-item label="陕西医保移动支付系统跟踪号区域平台交易跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入陕西医保移动支付系统跟踪号区域平台交易跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 " v-decorator="['ampTraceId']" />
        </a-form-item>
        <a-form-item label="平台结算跟踪号平台结算跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入平台结算跟踪号平台结算跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 " v-decorator="['traceId']" />
        </a-form-item>
        <a-form-item label="机构交易订单号该值与接口ORG_002(查询待结算费用列表与明细) 的返回值org_trace_no一样 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入机构交易订单号该值与接口ORG_002(查询待结算费用列表与明细) 的返回值org_trace_no一样 " v-decorator="['orgTraceNo']" />
        </a-form-item>
        <a-form-item label="机构编号(国标医院编码)机构的国家统一编码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入机构编号(国标医院编码)机构的国家统一编码 " v-decorator="['orgCode']" />
        </a-form-item>
        <a-form-item label="分院编号内部机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入分院编号内部机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 " v-decorator="['subOrgCode']" />
        </a-form-item>
        <a-form-item label="退款原因 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入退款原因 " v-decorator="['refundReason']" />
        </a-form-item>
        <a-form-item label="退款类型如果传02，则只支持全额退款（医保和自费全额进行退款）如果没有传入默认只退自费部分，如果有传入则至此对应类型的退款01 退“线上自费”02 退“医保和线上自费”  " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入退款类型如果传02，则只支持全额退款（医保和自费全额进行退款）如果没有传入默认只退自费部分，如果有传入则至此对应类型的退款01 退“线上自费”02 退“医保和线上自费”  " v-decorator="['refundType']" />
        </a-form-item>
        <a-form-item label="外部退款流水号，到时候查询退款结果根据此订单号可以进行查询，每个机构内保证唯一每个机构内保证唯一 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入外部退款流水号，到时候查询退款结果根据此订单号可以进行查询，每个机构内保证唯一每个机构内保证唯一 " v-decorator="['outRefundNo']" />
        </a-form-item>
        <a-form-item label="机构退款流水号自行调用机构系统进行退款后机构的退款订单号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入机构退款流水号自行调用机构系统进行退款后机构的退款订单号 " v-decorator="['orgRefundSn']" />
        </a-form-item>
        <a-form-item label="平台退款流水号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入平台退款流水号 " v-decorator="['refundTraceid']" />
        </a-form-item>
        <a-form-item label="区域平台退款流水号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入区域平台退款流水号 " v-decorator="['ampRefundId']" />
        </a-form-item>
        <a-form-item label="支付渠道退款流水号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入支付渠道退款流水号 " v-decorator="['payChnlRefundSn']" />
        </a-form-item>
        <a-form-item label="平台缴费单流水号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入平台缴费单流水号 " v-decorator="['orgTraceId']" />
        </a-form-item>
        <a-form-item label="支付渠道流水号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入支付渠道流水号 " v-decorator="['payChnlOrdsn']" />
        </a-form-item>
        <a-form-item label="省医保平台订单号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入省医保平台订单号 " v-decorator="['payOrdid']" />
        </a-form-item>
        <a-form-item label="交易状态SUCCESS 成功FAIL 失败INIT 初始化REFUND 全额退款EXP 系统异常，待核验ING 处理中 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入交易状态SUCCESS 成功FAIL 失败INIT 初始化REFUND 全额退款EXP 系统异常，待核验ING 处理中 " v-decorator="['tradeStatus']" />
        </a-form-item>
        <a-form-item v-show="false"><a-input v-decorator="['iD']" /></a-form-item>
        <a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择创建时间" v-decorator="['createDate']" @change="onChangecreateDate"/>
        </a-form-item>
        <a-form-item label="创建者Id" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入创建者Id" v-decorator="['createUserId']" />
        </a-form-item>
        <a-form-item label="创建者名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入创建者名称" v-decorator="['createUserName']" />
        </a-form-item>
        <a-form-item label="更新时间" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择更新时间" v-decorator="['modifyDate']" @change="onChangemodifyDate"/>
        </a-form-item>
        <a-form-item label="修改者Id" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入修改者Id" v-decorator="['modifyUserId']" />
        </a-form-item>
        <a-form-item label="修改者名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入修改者名称" v-decorator="['modifyUserName']" />
        </a-form-item>
        <a-form-item label="删除时间" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择删除时间" v-decorator="['deleteDate']" @change="onChangedeleteDate"/>
        </a-form-item>
        <a-form-item label="删除者ID" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入删除者ID" v-decorator="['deleteUserId']" />
        </a-form-item>
        <a-form-item label="删除者姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入删除者姓名" v-decorator="['deleteUserName']" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import moment from 'moment'
  import {
    NitfAmpHos002Edit
  } from '@/api/modular/main/NitfAmpHos002Manage'
  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        createDateDateString: '',
        modifyDateDateString: '',
        deleteDateDateString: '',
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
      moment,
      // 初始化方法
      edit (record) {
        this.visible = true
        setTimeout(() => {
          this.form.setFieldsValue(
            {
              iD: record.iD,
              psnNo: record.psnNo,
              ampTraceId: record.ampTraceId,
              traceId: record.traceId,
              orgTraceNo: record.orgTraceNo,
              orgCode: record.orgCode,
              subOrgCode: record.subOrgCode,
              refundReason: record.refundReason,
              refundType: record.refundType,
              outRefundNo: record.outRefundNo,
              orgRefundSn: record.orgRefundSn,
              refundTraceid: record.refundTraceid,
              ampRefundId: record.ampRefundId,
              payChnlRefundSn: record.payChnlRefundSn,
              orgTraceId: record.orgTraceId,
              payChnlOrdsn: record.payChnlOrdsn,
              payOrdid: record.payOrdid,
              tradeStatus: record.tradeStatus,
              createUserId: record.createUserId,
              createUserName: record.createUserName,
              modifyUserId: record.modifyUserId,
              modifyUserName: record.modifyUserName,
              deleteUserId: record.deleteUserId,
              deleteUserName: record.deleteUserName
            }
          )
        }, 100)
        this.form.getFieldDecorator('createDate', { initialValue: moment(record.createDate, 'YYYY-MM-DD') })
        this.createDateDateString = moment(record.createDate).format('YYYY-MM-DD')
        this.form.getFieldDecorator('modifyDate', { initialValue: moment(record.modifyDate, 'YYYY-MM-DD') })
        this.modifyDateDateString = moment(record.modifyDate).format('YYYY-MM-DD')
        this.form.getFieldDecorator('deleteDate', { initialValue: moment(record.deleteDate, 'YYYY-MM-DD') })
        this.deleteDateDateString = moment(record.deleteDate).format('YYYY-MM-DD')
      },
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            values.createDate = this.createDateDateString
            values.modifyDate = this.modifyDateDateString
            values.deleteDate = this.deleteDateDateString
            NitfAmpHos002Edit(values).then((res) => {
              if (res.success) {
                this.$message.success('编辑成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('编辑失败：' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      onChangecreateDate(date, dateString) {
        this.createDateDateString = dateString
      },
      onChangemodifyDate(date, dateString) {
        this.modifyDateDateString = dateString
      },
      onChangedeleteDate(date, dateString) {
        this.deleteDateDateString = dateString
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
